package com.my.test.java.http;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class App {

	
	public static void testUrl(String url){
		URL myUrl = null;
		try {
			myUrl = new URL(url);
			URLConnection urlConn = myUrl.openConnection();
			String myCookie = "4AOEWXM5QTBSTE2JQWW6VFWQ5ONB2XIYBIRIFH6IG3CJE7AO42JSOADXODLXW3HNVHY4QI333IIP5RJFDIIVBEQ3RRQSSECVMKAQQ67X2AXBBSUIRVU6SYWCDRVCILKVVVWQAUGFK43HZ6N3AF3SAO4QXMBVTFHOREII3MISVJP5KSPKGI6Q2LCVIJE57CUA5ODS2F3OKHOLOZMPHGB5FLHRPGAHOQQMXCG45EI44XNXNXKIULGAJOJSXYTDST4G7AEYPG32DT77UVVBQ65NQWB6MKHLRICJV5TKWFRW6A6BWKJE7RP2YKKOAH3IBEZVFOSFQPXW2WFDCQFWSSGVWGWJ364DUZHKD2X27QG2Y6PZJNXUCCGUWLI5GV3O43U6Y2M5FOIXB6P6MNMPJ562K5T3EVURJMBTFINQN7Q"; 
			
			urlConn.setRequestProperty("hi_dxh", myCookie);
			urlConn.connect();
			HttpURLConnection connection = null;
            if(urlConn instanceof HttpURLConnection){
            	connection = (HttpURLConnection) urlConn;
            }else{
            	System.out.println("Please enter an HTTP URL.");
            	return;
           }
           BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(),"utf-8"));
	       String urlString = "";
	       String current;
	       while((current = in.readLine()) != null){
	          urlString += current;
	       }
	       System.out.println(urlString);
		} catch (Exception e) {
			e.printStackTrace();
		} 
	}
	public static void main(String[] args) {
//		testUrl("http://www.baidu.com");
		testUrl("http://localhost:8089/minispring/haha?aa=hzb");
	}
}
